package com.zjitc.token;

import com.zjitc.dao.UsersDao;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/4/4 14:38
 * @description:
 */
@Component
public class Redis {

  public static Jedis jedis;

  @Autowired
  public Redis(Jedis jedis,UsersDao usersDao){
    jedis =new Jedis();
    System.out.println("连接成功");
    System.out.println("服务器正在运行:"+jedis.ping());

    List<String> usernameList= usersDao.findAllUsername();
    for (String username:usernameList){
      jedis.sadd("username",username);
    }
    List<String> emailList= usersDao.findAllemail();
    for (String email:emailList){
      jedis.sadd("email",email);
    }
  }
}
